package com.xk.meeting.back.controller;

import com.xk.meeting.service.AnnounceService;
import com.xk.meeting.service.AnnounceServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/addAnnounce")
public class AddAnnounceServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf8");
        String addtext = request.getParameter("addtext");

        AnnounceService announceService = new AnnounceServiceImpl();
        int count = announceService.addAnnounce(addtext);

        if (count > 0){
            request.setAttribute("msg","添加成功");
            request.getRequestDispatcher("addannounce.jsp").forward(request,response);
        }

    }
}
